package com.elitetyc.customview.activity;

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.elitetyc.customview.R;
import com.elitetyc.customview.custom.DialogEnum;
import com.elitetyc.customview.custom.GenderDialog;
import com.elitetyc.customview.custom.NoButtonDialog;
import com.elitetyc.customview.custom.OneButtonDialog;
import com.elitetyc.customview.custom.TwoButtonDialog;

public class DialogActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);
    }

    public void openDialog1(View view) {

        OneButtonDialog oneButtonDialog = new OneButtonDialog(this, DialogEnum.DIALOG_OK, "你好啊，对话框", "查看");
        oneButtonDialog.onButtonClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了按钮", Toast.LENGTH_SHORT).show();
                oneButtonDialog.dismiss();
            }
        });
        oneButtonDialog.show();

    }


    public void openDialog2(View view) {

        TwoButtonDialog twoButtonDialog = new TwoButtonDialog(this, DialogEnum.DIALOG_OK, "你好，两个按钮对话框", "确认", "取消");
        twoButtonDialog.setSureClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
                twoButtonDialog.dismiss();
            }
        });
        twoButtonDialog.setCancelClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了取消", Toast.LENGTH_SHORT).show();
                twoButtonDialog.dismiss();
            }
        });
        twoButtonDialog.show();

    }

    public void openDialog3(View view) {
        NoButtonDialog noButtonDialog = new NoButtonDialog(this,DialogEnum.DIALOG_OK,"延时对话框",2000);
        noButtonDialog.show();
    }

    public void openDialog4(View view) {
        TwoButtonDialog twoButtonDialog= new TwoButtonDialog(this, "上方大字", null);
        twoButtonDialog.setSureClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
                twoButtonDialog.dismiss();
            }
        });
        twoButtonDialog.setCancelClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了取消", Toast.LENGTH_SHORT).show();
                twoButtonDialog.dismiss();
            }
        });
        twoButtonDialog.show();
    }
    public void openDialog5(View view) {
        TwoButtonDialog twoButtonDialog= new TwoButtonDialog(this, "上方大字", "下方小字啦啦啦啦");
        twoButtonDialog.setSureClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
                twoButtonDialog.dismiss();
            }
        });
        twoButtonDialog.setCancelClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DialogActivity.this, "点击了取消", Toast.LENGTH_SHORT).show();
                twoButtonDialog.dismiss();
            }
        });
        twoButtonDialog.show();
    }

    public void openDialog6(View view) {
        GenderDialog genderDialog = new GenderDialog(this);
        genderDialog.setManClick((v)->{
            Toast.makeText(this, "点击了男", Toast.LENGTH_SHORT).show();
            genderDialog.dismiss();
        });
        genderDialog.setWoManClick((v)->{
            Toast.makeText(this, "点击了女", Toast.LENGTH_SHORT).show();
            genderDialog.dismiss();
        });
        genderDialog.setCancelClick((v)->{
            Toast.makeText(this, "点击了取消", Toast.LENGTH_SHORT).show();
            genderDialog.dismiss();
        });
        genderDialog.show();
    }
}
